<?php if (!defined('THINK_PATH')) exit();?>
<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
        <meta name="description" content="">
        <meta name="author" content="">

        <title>后台</title>

        <link href="/dk/Public/images/favicon.ico" rel="shortcut icon" />

        <!-- Bootstrap core CSS -->
        <link rel="stylesheet" href="/dk/Public/css/bootstrap.min.css" />
        <link rel="stylesheet" href="/dk/Public/css/bootstrap-theme.min.css" />
        <link rel="stylesheet" href="/dk/Public/css/dashboard.css" />
        <link rel="stylesheet" href="/dk/Public/css/bootstrap-switch.css" />
        <link rel="stylesheet" href="/dk/Public/css/icheck/all.css" />
        <link rel="stylesheet" href="/dk/Public/css/select2/select2.css" />
        <link href="/dk/Public/css/select2/select2-bootstrap.min.css" rel="stylesheet" />
    </head>

    <body>

    <nav class="navbar navbar-inverse navbar-fixed-top">
    <div class="container-fluid">
        <div class="navbar-header">
            <a class="navbar-brand" href="#"><img src="/dk/Public/images/logo.png"/></a>
        </div>
        <div id="navbar" class="navbar-collapse collapse">
            <ul class="nav navbar-nav navbar-right">
                <li><span>欢迎您：<?php echo ($_SESSION['userInfo']['real_name']); ?></span></li>
                
                <li><a href="<?php echo U('Admin/Auth/initAuth');?>">更新缓存</a></li>
                <li class="icon3"><a href="javascript:void(0);" onclick="common.modifyPwd('<?php echo U('Admin/User/modifyPwd');?>')">修改密码</a></li>
                <li class="icon2"><a href="<?php echo U('Admin/Login/login');?>">退出系统</a></li>
            </ul>
        </div>
    </div>
</nav>

<script type="text/javascript">
    var webRoot = "/dk";
</script>

    <div class="container-fluid">
        <div class="row">
            <link href="/dk/Public/css/font-awesome.min.css" rel="stylesheet">
<link href="/dk/Public/css/leftMenu.css" rel="stylesheet">
<div class="col-sm-3 col-md-2 sidebar">


    <ul id="accordion" class="accordion">
        <?php if(is_array($menuList)): $i = 0; $__LIST__ = $menuList;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><li thisC="<?php echo ($vo["controller"]); ?>">
            <?php if(empty($vo['subMenu'])): ?><div class="link" onclick="javascript:window.location.href = '<?php echo U($vo[url]);?>';" style="background-image: url('/dk/Public/images/icon/<?php echo ($vo["icon"]); ?>');"><?php echo ($vo["menuName"]); ?><i class="fa fa-chevron-down"></i></div>
                <?php else: ?>
                <div class="link" style="background-image: url('/dk/Public/images/icon/<?php echo ($vo["icon"]); ?>');"><?php echo ($vo["menuName"]); ?><i class="fa fa-chevron-down"></i></div>
                <ul class="submenu">
                        <?php if(is_array($vo['subMenu'])): $i = 0; $__LIST__ = $vo['subMenu'];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$v): $mod = ($i % 2 );++$i;?><li thisCF="<?php echo ($vo["controller"]); ?>_<?php echo ($v["function"]); ?>"><a href="<?php echo U($v['url']);?>"><?php echo ($v["menuName"]); ?></a></li><?php endforeach; endif; else: echo "" ;endif; ?>
                </ul><?php endif; ?>
                
            </li><?php endforeach; endif; else: echo "" ;endif; ?>
		
	</ul>
</div>
<script>

    var controllerName = "<?php echo ($controllerName); ?>";
    var actionName = "<?php echo ($actionName); ?>";
    
</script>
            <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
                <div class="cont-title clearfix">
                    <div class="title">内容列表</div>
                    <div class="btn-group"><button type="button" id="addNews"  class="btn">添加</button></div>
                </div>
                <form class="jc-search form-inline searchForm" action="<?php echo U('Admin/News/index');?>" method="post">
                    <div class="form-group">
                        <label>新闻标题:</label>
                        <input type="text" class="form-control" name="title" value="<?php echo ($title); ?>" placeholder="输入新闻标题">
                    </div>
                   
                  
                    <div class="form-group">
                        <label>新闻分类:</label>
                        <select name="cate_id" id="cateListSelect" style="width: 200px;" >
                            <option value="0">所有分类</option>
                            <?php if(is_array($cateList)): $i = 0; $__LIST__ = $cateList;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$cate): $mod = ($i % 2 );++$i;?><option <?php if($cate_id == $cate['id']): ?>selected="selected"<?php endif; ?> value="<?php echo ($cate["id"]); ?>" parent="<?php echo ($cate["pid"]); ?>"><?php echo ($cate["cate_name"]); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>
                        </select>
                    </div>
                    
                    <input class="btn" type="submit" value="搜索" />
                </form>
                <div class="table-responsive">
                    <table class="table table-striped table-hover" id="tableData">
                        <thead>
                            <tr>
                                <th>序号</th>
                                <th>标题</th>
                                <th>分类</th>
                                <th>作者</th>
                                <th>点击率</th>
                                <th>创建时间</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tbody>
                        <?php if(is_array($newsList['data'])): $i = 0; $__LIST__ = $newsList['data'];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$news): $mod = ($i % 2 );++$i;?><tr>
                                <td><?php echo ($i); ?></td>
                                <td><?php echo ($news["title"]); ?></td>
                                <td><?php echo (getCateName($news["cate_id"])); ?></td>
                                <td><?php echo (getUserName($news["user_id"])); ?></td>
                                <td><?php echo ($news["click"]); ?></td>
                                <td><?php echo (date('Y-m-d H:i:s',$news["create_time"])); ?></td>
                                <td>
                                    <a href="javascript:void(0)" newsId="<?php echo ($news["id"]); ?>" class="editNews">修改</a> | 
                            
                                <a href="javascript:void(0)" newsId="<?php echo ($news["id"]); ?>" class="delNews">删除</a>
                           
                            </td>
                            </tr><?php endforeach; endif; else: echo "" ;endif; ?>    
                        </tbody>
                    </table>
                    <div class="page">
                    	<?php echo ($newsList["page"]); ?>
                    </div>
                </div>
            </div>
        </div>
    </div>
    
<style type="text/css">
    @-moz-keyframes circles-loader {
        0% {
            -moz-transform: rotate(0deg);
            transform: rotate(0deg);
        }
        100% {
            -moz-transform: rotate(360deg);
            transform: rotate(360deg);
        }
    }

    @-webkit-keyframes circles-loader {
        0% {
            -webkit-transform: rotate(0deg);
            transform: rotate(0deg);
        }
        100% {
            -webkit-transform: rotate(360deg);
            transform: rotate(360deg);
        }
    }

    @keyframes circles-loader {
        0% {
            -moz-transform: rotate(0deg);
            -ms-transform: rotate(0deg);
            -webkit-transform: rotate(0deg);
            transform: rotate(0deg);
        }
        100% {
            -moz-transform: rotate(360deg);
            -ms-transform: rotate(360deg);
            -webkit-transform: rotate(360deg);
            transform: rotate(360deg);
        }
    }

    .circles-loader {
        position: absolute;
        top: 15px;
        left: 15px;
        width: 30px;
        height: 30px;
        text-align: center;
        line-height: 30px;
        font-size: 28px;
        -moz-animation: circles-loader 1s infinite linear;
        -webkit-animation: circles-loader 1s infinite linear;
        animation: circles-loader 1s infinite linear;

    }

    .card {
        position: relative;
        text-align: center;
        vertical-align: middle;
        width: 60px;
        height: 60px;
        margin: 0 auto;
    }
</style>
<!--  动态弹窗统一配置  -->    
<div class="modal fade" id="commonModal">
</div>
<!--       END         -->
<!--  ALERT  --> 

<div class="modal fade" id="alertModal" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title"></h4>
            </div>
            <div class="modal-body">
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" id="alertModalBtn" data-dismiss="modal">确定</button>
            </div>
        </div>
    </div>
</div>
<!--     ALERT   END        --> 

<!--  confirm CONFIRM  --> 

<div class="modal fade" id="confirmModal" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title"></h4>
            </div>
            <div class="modal-body">
            </div>
            <div class="modal-footer">
                <button type="button" id="confirmModalCancel" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" id="confirmModalBtn" data-dismiss="modal">确定</button>
            </div>
        </div>
    </div>
</div>

<!--  CONFIRM end --> 

<!-- LOADING -->
<div class="modal fade" id="loadModal" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-body">
                <div class="loading-title" style="text-align:center; font-size: 14px; font-weight: 700;"><p>内容加载中...请稍后...</p></div>

                <div class="card">
                    <span class="circles-loader glyphicon glyphicon-asterisk"></span>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- LOADING END -->
    <script type="text/javascript" src="/dk/Public/js/jquery.min.js"></script>
    <script type="text/javascript" src="/dk/Public/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="/dk/Public/js/bootstrap-switch.js"></script>
    <script type="text/javascript" src="/dk/Public/js/icheck.min.js"></script>
    <script type="text/javascript" src="/dk/Public/js/common.js"></script>
    <script type="text/javascript" src="/dk/Public/js/validator.min.js"></script>
    <script type="text/javascript" src="/dk/Public/js/ueditor/ueditor.config.js"></script>
    <script type="text/javascript" src="/dk/Public/js/ueditor/ueditor.all.js"></script>
    <script type="text/javascript" src="/dk/Public/js/select2/select2.js"></script>
    <script type="text/javascript" src="/dk/Public/js/select2tree.js"></script>
    <script>
        var Ue = null;
        $(function(){
            $("#cateListSelect").select2tree();
        })
        $("#tableData .editNews").click(function () {
            var newsId = $(this).attr("newsId");
            common.htmlAjax("<?php echo U('Admin/News/editNews');?>", {newsId: newsId}, function (html) {
                $("#commonModal").html(html).modal('toggle');
            })
        })

        $("#addNews").click(function () {
            common.htmlAjax("<?php echo U('Admin/News/addNews');?>", {}, function (html) {
                $("#commonModal").html(html).modal('toggle');
            })
        })

        $("#tableData .delNews").click(function () {
            var newsId = $(this).attr("newsId");
            common.confirm("提示", "确定删除新闻?", function () {
                common.ajax("<?php echo U('Admin/News/delNews');?>", {newsId: newsId}, function (data) {
                    //console.log(data);
                    common.alert("提示", "新闻删除成功!", function () {
                        common.reload();
                    });
                });
            });
        });

        $("#tableData .enUser").click(function () {
            var userId = $(this).attr("userId");
            common.confirm("提示", "确定启用用户?", function () {
                common.ajax("<?php echo U('Admin/User/enUser');?>", {userId: userId}, function (data) {
                    //console.log(data);
                    common.alert("提示", "用户启用成功!", function () {
                        common.reload();
                    });
                });
            });
        });
    </script>
</body>
</html>